Forward-port #11985: remove redundant required MDO attrs (#11979)#12347
Forward-port #11985: remove redundant required MDO attrs (#11979)#12347gnodet wants to merge 2 commits into
Conversation
Remove <required>true</required> from 13 metadata/defaulted fields in maven.mdo (forward-port of PR #11985 from maven-3.10.x). Update Model.name description to document artifactId fallback. Add minimal POM validation tests.
There was a problem hiding this comment.
Pull request overview
Forward-port of model-descriptor metadata cleanup to maven-4.0.x, removing redundant <required>true</required> flags from maven.mdo fields that are not actually validated as required, and adding regression tests/resources to ensure “minimal” raw models validate cleanly (with and without <parent>).
Changes:
- Removed redundant
requiredannotations from multiple fields inapi/maven-api-model/src/main/mdo/maven.mdo. - Added “minimal” raw-model POM fixtures (with/without parent) under test resources.
- Added compat
DefaultModelValidatorTestcoverage to assert zero violations for those minimal raw models.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
api/maven-api-model/src/main/mdo/maven.mdo |
Removes misleading required metadata; updates one field description. |
compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java |
Adds new tests to validate minimal raw models with/without parent. |
compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml |
Test POM fixture for “minimal with parent”. |
compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml |
Test POM fixture for “minimal without parent”. |
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java |
Removes outdated TODO comment related to nullable project name. |
impl/maven-impl/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml |
Adds impl-side copy of minimal fixture (currently unused). |
impl/maven-impl/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml |
Adds impl-side copy of minimal fixture (currently unused). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <field xdoc.separator="blank"> | ||
| <name>name</name> | ||
| <version>3.0.0+</version> | ||
| <required>true</required> | ||
| <description>The full name of the project.</description> | ||
| <description>The full name of the project. If not specified, the artifactId will be used.</description> | ||
| <type>String</type> |
There was a problem hiding this comment.
Good catch — updated the description to simply say "The full name of the project." without the misleading defaulting claim. The artifactId fallback is a runtime behavior in MavenProject#getName(), not a model-level default.
— Claude Opus 4.6, on behalf of Guillaume Nodet
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
|
||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>org.apache.maven.validation</groupId> | ||
| <artifactId>parent</artifactId> | ||
| <version>1</version> | ||
| </parent> | ||
|
|
||
| <artifactId>project</artifactId> | ||
|
|
||
| </project> |
There was a problem hiding this comment.
Good catch — confirmed this file is not referenced by any test in impl/maven-impl. The compat/maven-model-builder tests have their own copy. Removed.
— Claude Opus 4.6, on behalf of Guillaume Nodet
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
|
||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>groupId</groupId> | ||
| <artifactId>project</artifactId> | ||
| <version>project</version> | ||
|
|
||
| </project> |
There was a problem hiding this comment.
Same as above — confirmed unreferenced in impl/maven-impl. The compat/maven-model-builder tests have their own copy. Removed.
— Claude Opus 4.6, on behalf of Guillaume Nodet
- Fix <name> field description in maven.mdo to not claim the model field defaults to artifactId (the fallback is a runtime behavior in MavenProject#getName(), not a model-level default) - Remove unused test POM resources minimal-with-parent.xml and minimal-without-parent.xml from impl/maven-impl (only referenced in compat/maven-model-builder tests which have their own copies) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix <name> field description in maven.mdo to not claim the model field defaults to artifactId (the fallback is a runtime behavior in MavenProject#getName(), not a model-level default) Note: unlike the 4.0.x branch, the test POM resources minimal-with-parent.xml and minimal-without-parent.xml are actually referenced by tests in impl/maven-impl on master, so they are kept. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Forward-port of PR #11985 from maven-3.10.x to maven-4.0.x.
Removes
<required>true</required>from 13 fields inmaven.mdothat were never validated. No behavioral change — just corrects the model descriptor metadata.Ref: #11979